package com.ruoyi.admin.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.admin.vo.HospitalVO;
import com.ruoyi.admin.vo.UserRoleVO;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.admin.mapper.HospitalMapper;
import com.ruoyi.admin.domain.Hospital;
import com.ruoyi.admin.service.IHospitalService;

/**
 * 医院信息Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-23
 */
@Service
public class HospitalServiceImpl implements IHospitalService {
    @Autowired
    private HospitalMapper hospitalMapper;


    @Override
    public List<UserRoleVO> selectAllDuijie() {
        return hospitalMapper.selectAllDuijie();
    }

    @Override
    public List<UserRoleVO> selectAllGuDong() {
        return hospitalMapper.selectAllGuDong();
    }

    @Override
    public List<UserRoleVO> selectAllYiJi() {
        return hospitalMapper.selectAllYiJi();
    }

    @Override
    public List<UserRoleVO> selectAllErJi() {
        return hospitalMapper.selectAllErJi();
    }

    /**
     * 查询医院信息
     *
     * @param hospitalId 医院信息主键
     * @return 医院信息
     */
    @Override
    public Hospital selectHospitalByHospitalId(Long hospitalId) {



        return hospitalMapper.selectHospitalByHospitalId(hospitalId);
    }

    /**
     * 查询医院信息列表
     *
     * @param hospital 医院信息
     * @return 医院信息
     */
    @Override
    public List<Hospital> selectHospitalList(Hospital hospital) {
        return hospitalMapper.selectHospitalList(hospital);
    }

    @Override
    public List<HospitalVO> selectAllHospital(Hospital hospital) {
//        List<Hospital> hospitals = hospitalMapper.selectHospitalList(hospital);
//        List<HospitalVO> list = new ArrayList<>();
//        for (Hospital hosp : hospitals) {
//            HospitalVO hospitalVO = new HospitalVO();
//            hospitalVO.setHospitalId(hosp.getHospitalId());
//            hospitalVO.setHospitalName(hosp.getHospitalName());
//            hospitalVO.setCardNo(hosp.getCardNo());
//            hospitalVO.setCity(hosp.getCity());
//            hospitalVO.setDistrict(hosp.getDistrict());
//            hospitalVO.setProvince(hosp.getProvince());
//            hospitalVO.setRent(hosp.getRent());
//            hospitalVO.setGainSharing(hosp.getGainSharing());
//            hospitalVO.setShareholderId(hosp.getShareholderId());
//            hospitalVO.setDistributor1(hosp.getDistributor1());
//            hospitalVO.setDistributor2(hosp.getDistributor2());
//            hospitalVO.setUserId(hosp.getUserId());
//            hospitalVO.setDuijie("对接人");
//            hospitalVO.setErji("二级分销商");
//            hospitalVO.setYiji("一级分销商");
//            hospitalVO.setGudong("股东");
//
//            list.add(hospitalVO);
//        }
//        return list;

        return hospitalMapper.selectAllHospital(hospital);


    }

    /**
     * 新增医院信息
     *
     * @param hospital 医院信息
     * @return 结果
     */
    @Override
    public int insertHospital(Hospital hospital) {
        hospital.setCreateTime(DateUtils.getNowDate());
        return hospitalMapper.insertHospital(hospital);
    }

    /**
     * 修改医院信息
     *
     * @param hospital 医院信息
     * @return 结果
     */
    @Override
    public int updateHospital(Hospital hospital) {
        return hospitalMapper.updateHospital(hospital);
    }

    /**
     * 批量删除医院信息
     *
     * @param hospitalIds 需要删除的医院信息主键
     * @return 结果
     */
    @Override
    public int deleteHospitalByHospitalIds(Long[] hospitalIds) {
        return hospitalMapper.deleteHospitalByHospitalIds(hospitalIds);
    }

    /**
     * 删除医院信息信息
     *
     * @param hospitalId 医院信息主键
     * @return 结果
     */
    @Override
    public int deleteHospitalByHospitalId(Long hospitalId) {
        return hospitalMapper.deleteHospitalByHospitalId(hospitalId);
    }

    @Override
    public List<Hospital> selectAllHospital1() {
        return hospitalMapper.selectAllHospital1();
    }
}
